import { userLoginReq } from '@/api/user.api'
import { IUser, IUserLogin } from '@/types/user.type'
import { defineStore } from 'pinia'
import { reactive, ref, shallowRef } from 'vue'

export const useUserInfo = defineStore('user', () => {
    // 登录
    const userInfo = shallowRef<IUserLogin>({
        account: 'admin',
        password: 'admin'
    })
    // 获取登录后的信息
    let info = shallowRef<any>({})
    const login = async () => {
        const res = await userLoginReq(userInfo.value)
        console.log(res);
        localStorage.setItem('info', JSON.stringify(res.data.id))
        return res
    }
    return {
        userInfo,
        login,
        info
    }
}
)